package cn.jtfadmin.support.modules.mail.dto;


import java.io.Serializable;
import java.util.List;

/**
 * 基础发送邮件信息dto
 * @author jtf
 * @since 0.0.2
 */
public abstract class AbstractSendMailDTO implements Serializable {

    /**
     * smtp 主机名
     */
    protected String smtpHostName;

    /**
     * smtp 端口
     */
    protected Integer smtpPort;

    /**
     * 认证 用户名
     */
    protected String authenticatorUsername;

    /**
     * 认证 密码
     */
    protected String authenticatorPassword;

    /**
     * 是否是加密链接
     */
    protected boolean sslOnConnect;

    /**
     * 发送者邮箱
     */
    protected MailAddressDTO from;

    /**
     * 邮件主题
     */
    protected String subject;

    /**
     * 接收者邮箱
     */
    protected List<MailAddressDTO> toList;

    /**
     * 回复者邮件信息
     */
    protected List<MailAddressDTO> replyTo;

    public AbstractSendMailDTO() {
    }

    /**
     * 构造函数
     * @param smtpHostName smtp 域名， 非空
     * @param smtpPort smtp 端口号, ssl 465 ,STARTTLS 25, 可 null
     * @param authenticatorUsername 用户名 非空
     * @param authenticatorPassword 密码 非空
     * @param sslOnConnect 是否ssl
     * @param from 发送人 非空
     * @param subject  主题 非空
     * @param toList 接收人集合，非空
     * @param replyTo  回复人 可以为空集合，但不可为null
     */
    public AbstractSendMailDTO(String smtpHostName, Integer smtpPort, String authenticatorUsername, String authenticatorPassword, boolean sslOnConnect, MailAddressDTO from, String subject, List<MailAddressDTO> toList, List<MailAddressDTO> replyTo) {
        this.smtpHostName = smtpHostName;
        this.smtpPort = smtpPort;
        this.authenticatorUsername = authenticatorUsername;
        this.authenticatorPassword = authenticatorPassword;
        this.sslOnConnect = sslOnConnect;
        this.from = from;
        this.subject = subject;
        this.toList = toList;
        this.replyTo = replyTo;
    }

    public String getSmtpHostName() {
        return smtpHostName;
    }

    public void setSmtpHostName(String smtpHostName) {
        this.smtpHostName = smtpHostName;
    }

    public Integer getSmtpPort() {
        return smtpPort;
    }

    public void setSmtpPort(Integer smtpPort) {
        this.smtpPort = smtpPort;
    }

    public String getAuthenticatorUsername() {
        return authenticatorUsername;
    }

    public void setAuthenticatorUsername(String authenticatorUsername) {
        this.authenticatorUsername = authenticatorUsername;
    }

    public String getAuthenticatorPassword() {
        return authenticatorPassword;
    }

    public void setAuthenticatorPassword(String authenticatorPassword) {
        this.authenticatorPassword = authenticatorPassword;
    }

    public boolean isSslOnConnect() {
        return sslOnConnect;
    }

    public void setSslOnConnect(boolean sslOnConnect) {
        this.sslOnConnect = sslOnConnect;
    }

    public MailAddressDTO getFrom() {
        return from;
    }

    public void setFrom(MailAddressDTO from) {
        this.from = from;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public List<MailAddressDTO> getToList() {
        return toList;
    }

    public void setToList(List<MailAddressDTO> toList) {
        this.toList = toList;
    }

    public List<MailAddressDTO> getReplyTo() {
        return replyTo;
    }

    public void setReplyTo(List<MailAddressDTO> replyTo) {
        this.replyTo = replyTo;
    }

    /**
     * 邮件地址信息
     */
    public static class MailAddressDTO implements Serializable{

        /**
         * 地址
         */
        protected String address;

        /**
         * 名称
         */
        protected String name;

        public MailAddressDTO() {
        }

        public MailAddressDTO(String address, String name) {
            this.address = address;
            this.name = name;
        }

        public String getAddress() {
            return address;
        }

        public void setAddress(String address) {
            this.address = address;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }
}
